<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('strator_permissions', function (Blueprint $table) {
            $table->id();

            $table->unsignedInteger('pid')->default(0)->index()->comment('上级id，0为顶级');
            $table->string('permission_name')->nullable()->comment('权限名称');
            $table->string('module_name')->nullable()->comment('模块名称');
            $table->string('route')->unique()->nullable()->comment('路由');
            $table->integer('sort')->default(0)->index()->comment('排序');
            $table->string('icon')->nullable()->comment('图标');
            $table->tinyInteger('type')->default(1)->comment('类型：默认菜单1，按钮2，其他3');
            $table->string('permission_action')->nullable()->comment('permission route action');
            $table->tinyInteger('status')->default(1)->index()->comment('状态：默认1启用，0不启用');

            $table->timestamps();
            $table->softDeletes();
        });

        \DB::statement("ALTER TABLE `strator_permissions` comment '管理员权限表'");
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('strator_permissions');
    }
};
